home *** CD-ROM | disk | FTP | other *** search
/ Champak 140 / (Vol 140) Sep 19 2011.iso / Games / theLifeArk.swf / scripts / __Packages / soundManage / SoundManage.as
Encoding:
Text File  |  2011-09-19  |  7.1 KB  |  221 lines

  1. class soundManage.SoundManage
  2. {
  3.    var isMusicPlay;
  4.    var isSoundPlay;
  5.    var soundArray = new Array();
  6.    var musicArray = new Array();
  7.    function SoundManage()
  8.    {
  9.       _root.createEmptyMovieClip("mysound_mc",_root.getNextHighestDepth());
  10.       _root.createEmptyMovieClip("mymusic_mc",_root.getNextHighestDepth());
  11.       this.soundArray[0] = new Array();
  12.       this.soundArray[1] = new Array();
  13.       this.soundArray[2] = new Array();
  14.       this.musicArray[0] = new Array();
  15.       this.musicArray[1] = new Array();
  16.       this.musicArray[2] = new Array();
  17.       this.addMusic("main_s");
  18.       if(this.isMusicPlay == undefined)
  19.       {
  20.          this.isMusicPlay = true;
  21.          this.playMusic("main_s",9999);
  22.       }
  23.       if(this.isSoundPlay == undefined)
  24.       {
  25.          this.isSoundPlay = true;
  26.       }
  27.    }
  28.    function addSound()
  29.    {
  30.       switch(arguments.length)
  31.       {
  32.          case 1:
  33.             this.soundArray[0].push(arguments[0]);
  34.             _root.mysound_mc.createEmptyMovieClip(arguments[0] + "_sound",_root.mysound_mc.getNextHighestDepth());
  35.             var _loc4_ = new Sound(_root.mysound_mc[arguments[0] + "_sound"]);
  36.             _loc4_.attachSound(arguments[0]);
  37.             this.soundArray[1].push(_loc4_);
  38.             this.soundArray[2].push(100);
  39.             break;
  40.          case 2:
  41.             if(arguments[1] > 100)
  42.             {
  43.                arguments[1] = 100;
  44.             }
  45.             else if(arguments[1] < 0)
  46.             {
  47.                arguments[1] = 0;
  48.             }
  49.             this.soundArray[0].push(arguments[0]);
  50.             _root.mysound_mc.createEmptyMovieClip(arguments[0] + "_sound",_root.mysound_mc.getNextHighestDepth());
  51.             _loc4_ = new Sound(_root.mysound_mc[arguments[0] + "_sound"]);
  52.             _loc4_.attachSound(arguments[0]);
  53.             _loc4_.setVolume(arguments[1]);
  54.             this.soundArray[1].push(_loc4_);
  55.             this.soundArray[2].push(arguments[1]);
  56.       }
  57.    }
  58.    function addMusic()
  59.    {
  60.       switch(arguments.length)
  61.       {
  62.          case 1:
  63.             this.musicArray[0].push(arguments[0]);
  64.             _root.mymusic_mc.createEmptyMovieClip(arguments[0] + "_sound",_root.mymusic_mc.getNextHighestDepth());
  65.             var _loc4_ = new Sound(_root.mymusic_mc[arguments[0] + "_sound"]);
  66.             _loc4_.attachSound(arguments[0]);
  67.             this.musicArray[1].push(_loc4_);
  68.             this.musicArray[2].push(100);
  69.             break;
  70.          case 2:
  71.             if(arguments[1] > 100)
  72.             {
  73.                arguments[1] = 100;
  74.             }
  75.             else if(arguments[1] < 0)
  76.             {
  77.                arguments[1] = 0;
  78.             }
  79.             this.musicArray[0].push(arguments[0]);
  80.             _root.mymusic_mc.createEmptyMovieClip(arguments[0] + "_sound",_root.mymusic_mc.getNextHighestDepth());
  81.             _loc4_ = new Sound(_root.mymusic_mc[arguments[0] + "_sound"]);
  82.             _loc4_.attachSound(arguments[0]);
  83.             _loc4_.setVolume(arguments[1]);
  84.             this.musicArray[1].push(_loc4_);
  85.             this.musicArray[2].push(arguments[1]);
  86.       }
  87.    }
  88.    function stopSound()
  89.    {
  90.       this.isSoundPlay = false;
  91.       var _loc2_ = 0;
  92.       while(_loc2_ <= this.soundArray[1].length)
  93.       {
  94.          this.soundArray[1][_loc2_].setVolume(0);
  95.          _loc2_ = _loc2_ + 1;
  96.       }
  97.    }
  98.    function stopMusic()
  99.    {
  100.       this.isMusicPlay = false;
  101.       var _loc2_ = 0;
  102.       while(_loc2_ <= this.musicArray[1].length)
  103.       {
  104.          this.musicArray[1][_loc2_].setVolume(0);
  105.          _loc2_ = _loc2_ + 1;
  106.       }
  107.    }
  108.    function returnSound()
  109.    {
  110.       this.isSoundPlay = true;
  111.       var _loc2_ = 0;
  112.       while(_loc2_ < this.soundArray[1].length)
  113.       {
  114.          this.soundArray[1][_loc2_].setVolume(this.soundArray[2][_loc2_]);
  115.          _loc2_ = _loc2_ + 1;
  116.       }
  117.    }
  118.    function returnMusic()
  119.    {
  120.       this.isMusicPlay = true;
  121.       var _loc2_ = 0;
  122.       while(_loc2_ < this.musicArray[1].length)
  123.       {
  124.          this.musicArray[1][_loc2_].setVolume(this.musicArray[2][_loc2_]);
  125.          _loc2_ = _loc2_ + 1;
  126.       }
  127.    }
  128.    function playSound()
  129.    {
  130.       if(this.isSoundPlay == true)
  131.       {
  132.          switch(arguments.length)
  133.          {
  134.             case 1:
  135.                var _loc3_ = 0;
  136.                while(_loc3_ <= this.soundArray[0].length)
  137.                {
  138.                   if(this.soundArray[0][_loc3_] == arguments[0])
  139.                   {
  140.                      this.soundArray[1][_loc3_].start(0,1);
  141.                      break;
  142.                   }
  143.                   _loc3_ = _loc3_ + 1;
  144.                }
  145.                break;
  146.             case 2:
  147.                _loc3_ = 0;
  148.                while(_loc3_ <= this.soundArray[0].length)
  149.                {
  150.                   if(this.soundArray[0][_loc3_] == arguments[0])
  151.                   {
  152.                      this.soundArray[1][_loc3_].start(0,arguments[1]);
  153.                      break;
  154.                   }
  155.                   _loc3_ = _loc3_ + 1;
  156.                }
  157.                break;
  158.             case 3:
  159.                _loc3_ = 0;
  160.                while(_loc3_ <= this.soundArray[0].length)
  161.                {
  162.                   if(this.soundArray[0][_loc3_] == arguments[0])
  163.                   {
  164.                      this.soundArray[1][_loc3_].setVolume(arguments[2]);
  165.                      this.soundArray[1][_loc3_].start(0,arguments[1]);
  166.                      this.soundArray[1][_loc3_].setVolume(this.soundArray[2][_loc3_]);
  167.                      break;
  168.                   }
  169.                   _loc3_ = _loc3_ + 1;
  170.                }
  171.          }
  172.       }
  173.    }
  174.    function playMusic()
  175.    {
  176.       if(this.isMusicPlay == true)
  177.       {
  178.          switch(arguments.length)
  179.          {
  180.             case 1:
  181.                var _loc3_ = 0;
  182.                while(_loc3_ <= this.musicArray[0].length)
  183.                {
  184.                   if(this.musicArray[0][_loc3_] == arguments[0])
  185.                   {
  186.                      this.musicArray[1][_loc3_].start(0,1);
  187.                      break;
  188.                   }
  189.                   _loc3_ = _loc3_ + 1;
  190.                }
  191.                break;
  192.             case 2:
  193.                _loc3_ = 0;
  194.                while(_loc3_ <= this.musicArray[0].length)
  195.                {
  196.                   if(this.musicArray[0][_loc3_] == arguments[0])
  197.                   {
  198.                      this.musicArray[1][_loc3_].start(0,arguments[1]);
  199.                      break;
  200.                   }
  201.                   _loc3_ = _loc3_ + 1;
  202.                }
  203.                break;
  204.             case 3:
  205.                _loc3_ = 0;
  206.                while(_loc3_ <= this.musicArray[0].length)
  207.                {
  208.                   if(this.musicArray[0][_loc3_] == arguments[0])
  209.                   {
  210.                      this.musicArray[1][_loc3_].setVolume(arguments[2]);
  211.                      this.musicArray[1][_loc3_].start(0,arguments[1]);
  212.                      this.musicArray[1][_loc3_].setVolume(this.musicArray[2][_loc3_]);
  213.                      break;
  214.                   }
  215.                   _loc3_ = _loc3_ + 1;
  216.                }
  217.          }
  218.       }
  219.    }
  220. }
  221.